load("//bzl:cpp_library.bzl", "cpp_library")
load("//bzl:cpp_unittest.bzl", "cpp_unittest")

package(default_visibility = ["//visibility:public"])

cpp_unittest(
    name = "channel_processor_test",
    srcs = ["ChannelProcessorTest.cpp"],
    deps = [
        "//folly/channels:channel_processor",
        "//folly/executors:manual_executor",
        "//folly/portability:gmock",
    ],
)

# TODO(kgk): Fix test.
# cpp_unittest(
#     name = "channel_test",
#     srcs = ["ChannelTest.cpp"],
#     size = ["medium"],
#     deps = [
#         "//folly/channels:channel",
#         "//folly/channels/test:channel_test_util",
#         "//folly/coro:blocking_wait",
#         "//folly/executors:manual_executor",
#         "//folly/portability:gtest",
#     ],
# )

# TODO(kgk): Fix test.
# cpp_unittest(
#     name = "fanout_channel_test",
#     srcs = ["FanoutChannelTest.cpp"],
#     deps = [
#         "//folly/channels:consume_channel",
#         "//folly/channels:fanout_channel",
#         "//folly/channels/test:channel_test_util",
#         "//folly/executors:manual_executor",
#         "//folly/executors:serial_executor",
#         "//folly/portability:gmock",
#         "//folly/portability:gtest",
#     ],
# )

cpp_unittest(
    name = "fanout_sender_test",
    srcs = ["FanoutSenderTest.cpp"],
    deps = [
        "//folly/channels:consume_channel",
        "//folly/channels:fanout_sender",
        "//folly/channels/test:channel_test_util",
        "//folly/executors:manual_executor",
        "//folly/executors:serial_executor",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "max_concurrent_rate_limiter_test",
    srcs = [
        "MaxConcurrentRateLimiterTest.cpp",
    ],
    deps = [
        "//folly/channels:max_concurrent_rate_limiter",
        "//folly/executors:manual_executor",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

# TODO(kgk): Fix test.
# cpp_unittest(
#     name = "merge_channel_test",
#     srcs = [
#         "MergeChannelTest.cpp",
#     ],
#     deps = [
#         "//folly/channels:consume_channel",
#         "//folly/channels:merge_channel",
#         "//folly/channels/test:channel_test_util",
#         "//folly/executors:manual_executor",
#         "//folly/executors:serial_executor",
#         "//folly/portability:gmock",
#         "//folly/portability:gtest",
#     ],
# )

# TODO(kgk): Fix test.
# cpp_unittest(
#     name = "merge_test",
#     srcs = ["MergeTest.cpp"],
#     deps = [
#         "//folly/channels:consume_channel",
#         "//folly/channels:merge",
#         "//folly/channels/test:channel_test_util",
#         "//folly/executors:manual_executor",
#         "//folly/executors:serial_executor",
#         "//folly/portability:gmock",
#         "//folly/portability:gtest",
#     ],
# )

# TODO(kgk): Fix test.
# cpp_unittest(
#     name = "multiplex_channel_test",
#     srcs = ["MultiplexChannelTest.cpp"],
#     deps = [
#         "//folly/channels:consume_channel",
#         "//folly/channels:max_concurrent_rate_limiter",
#         "//folly/channels:multiplex_channel",
#         "//folly/channels/test:channel_test_util",
#         "//folly/coro:blocking_wait",
#         "//folly/executors:manual_executor",
#         "//folly/executors:serial_executor",
#         "//folly/portability:gmock",
#         "//folly/portability:gtest",
#     ],
# )

cpp_unittest(
    name = "producer_test",
    srcs = ["ProducerTest.cpp"],
    deps = [
        "//folly/channels:producer",
        "//folly/channels/test:channel_test_util",
        "//folly/executors:manual_executor",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "proxy_channel_test",
    srcs = ["ProxyChannelTest.cpp"],
    deps = [
        "//folly/channels:proxy_channel",
        "//folly/channels/test:channel_test_util",
        "//folly/executors:manual_executor",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

# TODO(kgk): Fix test.
# cpp_unittest(
#     name = "transform_test",
#     srcs = ["TransformTest.cpp"],
#     deps = [
#         "//folly:scope_guard",
#         "//folly:synchronized",
#         "//folly/channels:consume_channel",
#         "//folly/channels:max_concurrent_rate_limiter",
#         "//folly/channels:transform",
#         "//folly/channels/test:channel_test_util",
#         "//folly/coro:async_generator",
#         "//folly/coro:detach_on_cancel",
#         "//folly/executors:manual_executor",
#         "//folly/executors:serial_executor",
#         "//folly/portability:gmock",
#         "//folly/portability:gtest",
#     ],
# )

cpp_library(
    name = "channel_test_util",
    hdrs = ["ChannelTestUtil.h"],
    deps = [
        "//folly/channels:consume_channel",
        "//folly/coro:detach_on_cancel",
        "//folly/coro:sleep",
        "//folly/executors:cpu_thread_pool_executor",
        "//folly/executors:io_thread_pool_executor",
        "//folly/executors:sequenced_executor",
        "//folly/futures:shared_promise",
        "//folly/portability:gmock",
    ],
)
